﻿using CommandLine;
using System.Reflection;
using PCore = PBIW.Core.Core;
using SysConsole = System.Console;

namespace PBIW.Console.Commands
{
    public static class VersionCommand
    {
        [Verb("version", HelpText = "获取版本信息。")]
        public sealed class Options : IOption { }

        public sealed class Executor : IExecutor<Options>
        {
            private readonly PCore core;
            public Executor(PCore core)
            {
                this.core = core;
            }
            public void Execute(Options options)
            {
                var ver = Assembly.GetExecutingAssembly().GetName().Version;
                var verStr = ver is null ? "ersion unknown" : ver.ToString(3);

                SysConsole.WriteLine($"版本信息如下：");
                SysConsole.WriteLine($"===============================");

                SysConsole.WriteLine($"您正在运行：" +
                    $"{this.core.StartingArguments.ApplicationId} （ v{verStr} ）");
                SysConsole.WriteLine($"程序所在目录：{AppContext.BaseDirectory}");
                SysConsole.WriteLine($"配置所在路径：{this.core.SettingsFilePath}");
                SysConsole.WriteLine($"想了解更多内容，可以访问我们的仓库：" +
                    $"https://gitee.com/yueyinqiu5990/plum-blossom-in-winter-console.git");

                SysConsole.WriteLine($"===============================");
            }
        }
    }
}